import Vue from 'vue';
import App from './App.vue';
import VueCompositionAPI from '@vue/composition-api';
import { AppType } from '@/types/index';
import '@/filters/index';
import './utils/global/index';
import GoEasy from 'goeasy';
import uView from 'uview-ui';
import UniCompositionHooks from '@/hooks/uniapp-composition-hooks/index';
import { useGoEasy } from './hooks/go-easy.hooks';
Vue.use(uView);

// 使用composition-api方式
Vue.use(VueCompositionAPI);
Vue.use(UniCompositionHooks);

Vue.config.productionTip = false;

// 注入mpType属性
(App as unknown as AppType).mpType = 'app';

const app = new Vue({
  ...App
});
app.$mount();

Vue.prototype.GoEasy = GoEasy;
Vue.prototype.goEasy = useGoEasy();

Vue.prototype.formatDate = function (t: number) {
  t = t || Date.now();
  const time = new Date(t);
  let str = time.getMonth() < 9 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1;
  str += '-';
  str += time.getDate() < 10 ? '0' + String(time.getDate()) : String(time.getDate());
  str += ' ';
  str += String(time.getHours());
  str += ':';
  str += time.getMinutes() < 10 ? '0' + String(time.getMinutes()) : String(time.getMinutes());
  return str;
};
